﻿
define(['jquery', '../javascripts/i18next-1.5.10', 'lib/class', 'lib/underscore.min', 'lib/stacktrace', 'util'], function($) {
    
    document.addEventListener("deviceready", function () {

    try {
        cordova.exec(null, null,'BrowserQuestWP8.Plugins.Ads','HideAds',[]);
    } catch (e) {
    }

    cordova.exec(
        function(langCode){

            //Load localized images by CSS
            var css = $("<link>");
            css.attr({
                rel:  "stylesheet",
                type: "text/css",
                href: "css/lang/" + langCode + "/main.css"
            });
            $("head").append(css);
            
            //Should be getAsync:true for Windows Phone to work
            var option = { resGetPath: '/www/strings/' + langCode + '/__ns__.txt', debug: true , getAsync: true, keyseparator : '---',
                ns: { namespaces: ['resources'], defaultNs: 'resources'} , fallbackLng : 'en-US'
            };
            
            i18n.init(option, function (t) {
                $('body').i18n();

                window.gls = function (key) {
                    return i18n.t(key);
                };
                //ready to play
                require(["main"]);
            });
        },
        function(){
            
        },
        'BrowserQuestWP8.Plugins.Language',
        'language',
        []
        );
        

    }, false);
});